package com.ikingtech.platform.service.authentication.converter;

import com.ikingtech.platform.service.authentication.web.AuthenticationRequest;
import jakarta.servlet.http.HttpServletRequest;
import lombok.RequiredArgsConstructor;

import java.util.List;

/**
 * @author tie yan
 */
@RequiredArgsConstructor
public class AuthenticateConverterManager implements AuthenticateConverter{

    private final List<AuthenticateConverter> converters;

    @Override
    public AuthenticationRequest convert(HttpServletRequest request) {
        AuthenticationRequest authenticationRequest = null;

        for (AuthenticateConverter converter : this.converters) {
            authenticationRequest = converter.convert(request);
            if (null != authenticationRequest) {
                break;
            }
        }
        return authenticationRequest;
    }
}
